package com.sfang.common.base.exception;

/**
 * @Desc
 * @Class TransTypeS
 * @Author Jimmy
 * @Date 0006 2017/4/6
 */
public enum ExceptionType {
    /**
     * 公共模块
     */
    InvalidParams("40001", "非法的参数"),
    NotAccepted("40006", "获取乐观锁失败"),
    UnkonwnError("40500", "未知错误"),
    EsAddError("40560", "Es add error"),
    EsUpdateError("40561", "Es update error"),
    InterruptedException("40562", "InterruptedException"),
    MatchRoutingNotExists("400404", "找不到匹配的路由"),
    RequestRejectedException("400403", "服务被拒绝"),

    /**
     * 用户模块
     */
    ReadingsCartoonSchemaNotExists("71001", "找不到匹配的表名"),
    ReadingsCartoonNotExists("71002", "找不到匹配的漫画阅读历史"),
    BookmarkCartoonSchemaNotExists("71003", "找不到匹配的表名"),
    BookmarkCartoonNotExists("71004", "找不到匹配的漫画书签"),
    ReadingsNovelSchemaNotExists("71005", "找不到匹配的表名"),
    ReadingsNovelNotExists("71006", "找不到匹配的小说阅读历史"),
    BookmarkNovelSchemaNotExists("71007", "找不到匹配的表名"),
    BookmarkNovelNotExists("71008", "找不到匹配的小说书签"),
    TransferFullException("71009", "全量同步发送消息队列异常"),
    TransferIncrException("71010", "增量同步发送消息队列异常"),
    TransferFullSwitchClose("71011", "transferFullSwitch处于关闭状态,停止用户全量更新"),
    UserEMailTooManny("71030", "一个邮箱有多账号"),
    UserNotExist("71031", "用户不存在"),
    UserEmailNotExist("71032", "该邮箱无法找到用户信息"),
    UserAlreadyExists("71033", "该用户信息已经被注册"),
    UserNickNameTooManny("71034", "该用户昵称有多个账号"),
    UserNickNameNotExist("71035", "该用户昵称不存在"),
    UserPhoneTooManny("71036", "该手机号有多个账号"),
    UserPhoneNotExist("71037", "手机号不存在"),
    UserBindingTooManny("71038", "一个用户绑定多个第三方账号"),
    UserBindingNotExist("71039", "该用户没有绑定第三方账号"),
    UserUpdatePwdNoParameters("71040", "修改密码需要手机号或者邮箱"),
    UserNameTooManny("71041", "该用户名有多个账号"),
    UserNameNotExist("71042", "该用户名不存在"),
    InvalidOldPassword("71043", "请输入正确的原始密码"),
    InvalidCaptcha("71044", "无效验证码"),
    UserNameAndPwdFailed("71045", "用户名或密码不正确"),
    UserPhoneAlreadyExists("71046", "手机号已绑定"),
    UserEmailAlreadyExists("71047", "邮箱已注册"),
    InvalidPhone("71048", "请输入正确手机号"),

    InvalidEmail("71049", "请输入正确邮箱"),
    UserVerifyCodeFail("71050", "验证码错误"),
    UserSendPhoneMsgFail("71051", "手机短信发送错误"),
    UserSendEmailFail("71052", "邮件发送错误"),
    UserPhoneOrEmailFail("71053", "请输入正确手机号或者邮箱"),
    InvalidPhoneCaptcha("71054", "短信验证码错误"),
    UserTooMannyFail("71055", "该用户有多条数据"),
    DeviceNotExist("71056", "设备不存在"),
    DeviceNoTooMannyFail("71057", "设备号存在多条"),
    DeviceNoTypeNotExist("71058", "设备号类型不能为空"),
    MatchSignFail("71059", "签名验证失败"),
    CaptchaImageGetFail("71060", "图片验证码获取失败"),
    UserDisable("71061", "用户已被禁用"),
    UserUnnormal("71062", "用户异常"),
    UserDisclosure("71063", "用户被封禁"),
    PasswordMachFail("71064", "密码由6-20位字母、数字和字符组成"),
    InvalidPhoneAreaCode("71065", "请输入正确的AreaCode"),
    InvalidAppKey("71066", "请输入正确的AppKey"),
    InvalidOriginPhone("71067", "请输入正确的老手机号码"),
    InvalidRegiserMode("71068", "非法的注册模式"),
    InvalidEmailResetPassword("71069", "验证失败"),
    HasAlreadyBinding("71070", "用户已绑定过该帐号"),
    BindingNotExist("71071", "绑定帐号不存在"),
    HasBindingedToOthers("71072", "该帐号已绑定到其他用户"),
    UserSchemaNotExists("71073", "找不到匹配的表名"),
    UserLoginSchemaNotExists("71074", "找不到匹配的表名"),
    DuplicateKeyException("71075", "DuplicateKeyException"),
    DataIntegrityViolationException("71076", "DataIntegrityViolationException"),
    UserLoginNotExists("71077", "用户登录纪录不存在"),
    UserLoginUserIdNotExists("71078", "用户登录纪录用户Id不存在"),
    ClientAbortException("71100", "ClientAbortException"),


    /**
     * 支付模块
     */
    TransNoNotExist("60002", "流水号不存在"),
    InvalidTransNo("60003", "非法的流水号"),
    TransNoOccupied("60004", "流水号已经被占用"),
    AlreadyPay("60005", "此订单已经发起支付了,请等待支付结果"),
    RepeatPay("60006", "此订单已经支付成功了,请勿重复支付"),
    InvalidOrderNo("60007", "非法的订单号"),
    AlreadyApplaySettlement("60008", "此订单已经申请过结算,勿需重复申请"),
    NotExistSettlementRecord("60009", "结算失败,不存在待结算的数据"),
    AlreadySettlemented("600010", "此订单已经发起结算,请勿重复结算"),
    ExistPendingWithdraw("600011", "你有提现单在处理中,请稍后再试"),
    AlipayPrePayFeeFailure("600012", "拉取支付手续费失败"),
    AlipayWithdrawalFeeFailure("600013", "拉取提现手续费失败"),
    CheckWithdrawalFailure("600014", "提现前置条件判断失败"),
    WithdrawalAccountNotExists("600015", "提现帐号不存在"),
    InvalidSign("600016", "签名错误"),
    PrepayNotExists("600017", "预支付订单号不存在"),
    PaymentNotExists("600018", "支付单号不存在"),
    ParsePrecalibrationParamsFailure("600019", "解析校验接口参数失败"),
    PrecalibrationFailure("600020", "聚合支付校验失败"),
    PrecalibrationException("600021", "聚合支付校验异常"),
    InvalidCallbackParams("600022", "非法的回调参数"),
    RetrieveEBeiJiaPayURLError("600023", "获取益倍嘉跳转url失败"),
    PaymentStatusChanged("600024", "支付状态已变更,请勿再次发起支付"),
    PaymentWayNotExists("600025", "商户号无可用的支付通道"),
    RetrieveFastbillUnionPayURLError("600026", "获取快钱UnionPay跳转url失败"),
    RetrieveQuickPaymentBindingCardsError("600027", "获取快捷支付绑定卡异常"),
    QuickPaymentBindingCaptchaError("600028", "快捷支付绑卡获取验证码异常"),
    QuickPaymentBindingError("600029", "快捷支付绑定卡异常"),
    QuickPaymentCaptchaError("600030", "快捷支付获取验证码异常"),
    QuickPaymentPayError("600031", "快捷支付异常"),
    QuickPaymentBankUnsupport("600032", "快捷支付暂不支持该银行"),
    QuickPaymentAlreadyBinding("600034", "快捷支付该卡已经绑定，请勿重复绑定"),
    InvalidCardBin("600035", "抱歉，未匹配出银行类型"),
    WithholdError("600036", "代扣异常，请稍后再试"),
    RelaunchPay("600037", "重新发起，旧单据废弃"),
    CreateBusinessOrderFailed("600038", "创建业务单异常"),
    ThirdPayGatewayRequestError("600039", "和支付网关交互异常"),

    ConfirmTradeError("600040", "ConfirmTrade异常"),
    RechargePackageError("600041", "ConfirmTrade异常"),
    ThirdPayGatewayQueryError("600042", "ThirdPayGatewayQueryError异常"),
    GatewayAdyenSdkSetupError("600043", "GatewayAdyenSdkSetupError异常"),
    GatewayAdyenSdkVerifyError("600044", "GatewayAdyenSdkVerifyError异常"),
    ThirdPayAppleTicketRequestError("600045", "和支付网关交互异常"),

    /**
     * wallet模块
     */
    UserIdNotExist("1000", "获取不到用户Id"),
    WalletBalanceInsufficient("1001", "馀额不足"),
    CouponExceedUpperQuantity("1002", "超出上限"),
    CouponExceedDeviceDayTimesUpperQuantity("1003", "超出设备每天领取上限"),
    CouponExceedDeviceTotalTimesUpperQuantity("1004", "超出设备总领取上限"),
    OrderPayNotExists("1005", "支付单号不存在"),
    OrderRechargeNottExists("1006", "充值单号不存在"),
    OrderRechargeExistPending("1007", "存为非终态的充值单"),
    ReadingCouponSettingsNotExist("1008", "ReadingCouponSettings不存在"),
    OrderRechargeStatusChanged("1009", "充值单已存在终态，请勿重复提交"),
    CouponSettingsNotValidDate("1010", "当前时间不在该阅读券发放有效期"),
    CouponSettingsNotProcessing("1011", "该阅读券投放未开始或已结束"),
    RechargeGoodsNotExists("1012", "充值商品不存在"),
    PromotionNotExists("1013", "促销活动不存在"),
    DecryptFailed("1014", "解密失败"),
    CouponSettingsNotValidStatus("1015", "该阅读券当前状态不能进行领取"),
    SubaccountFirstRechargeGiftPackError("1016", "SubaccountFirstRechargeGiftPackError异常"),
    SubaccountAdRewardSettingsError("1017", "SubaccountAdRewardSettingsError"),
    AreaGroupRetrieveError("1018", "AreaGroupRetrieveError"),
    OrderPayMangaCoinMissing("1019", "消费单次元币数据缺失"),
    OrderPayGiftCoinMissing("1020", "消费单赠币数据缺失"),
    InvalidApplicationParameter("41000", "请求方法的应用级输入参数错误"),
    CalculateUserBalanceError("1021", "calculate钱包余额异常"),
    StatisticalUserAmountError("1022", "statistical钱包余额异常"),
    OrderRechargeMissing("1023", "充值单数据缺失"),
    OrderRechargeDetailMissing("1024", "orderRechargeDetail数据缺失"),
    OrderPayDetailMissing("1025", "orderPayDetail数据缺失"),
    UserCouponMissing("1026", "userCoupon数据缺失"),
    OrderGoodsMissing("1027", "orderGoods数据缺失"),
    OrderGoodsDetailMissing("1028", "orderGoodsDetail消费单次元币数据缺失"),
    OrderPayMissing("1029", "orderPayMissing数据缺失"),
    IPAreaRequestError("1030", "根据IP获取区域失败"),

    VideoLaunchClinetError("1031", "根据IP获取区域失败"),

    RewardSettingsNoNotExist("1200", "RewardSettingsNo不存在"),
    PropsNoNotExist("1201", "PropsNoNotExist"),
    AlreadyGain("1202", "已经领取过了"),

    MangaAssociateIdOccupied("1600", "已经领取过了"),

    ;


    ExceptionType(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private String code;
    private String desc;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static ExceptionType handleCode(String code) {
        if (code == null) return null;
        for (ExceptionType types : ExceptionType.values()) {
            if (types.getCode().equals(code))
                return types;
        }
        return null;
    }

    public static ExceptionType handleDesc(String desc) {
        if (desc == null) return null;
        for (ExceptionType types : ExceptionType.values()) {
            if (types.getDesc().equals(desc))
                return types;
        }
        return null;
    }
}
